package com.lianbang.pharmacy.module.search

import android.os.Bundle
import android.view.View
import cn.ubest.mvvmcore.base.BaseFragment
import com.google.android.flexbox.FlexboxLayoutManager
import com.lianbang.pharmacy.R
import com.lianbang.pharmacy.adapter.HistorySearchListAdapter
import com.lianbang.pharmacy.databinding.FragmentSearchHistoryBinding
import com.lianbang.pharmacy.vm.MedicineVM
import kotlinx.android.synthetic.main.fragment_search_history.*

/**
 * Created by maoqi on 2020/11/23.
 */
class SearchHistoryFragment : BaseFragment<MedicineVM, FragmentSearchHistoryBinding>() {
    private val mHotSearchAdapter by lazy {
        HistorySearchListAdapter()
    }
    private val mHistorySearchAdapter by lazy {
        HistorySearchListAdapter()
    }

    companion object {
        fun newInstance(): SearchHistoryFragment {
            return SearchHistoryFragment()
        }
    }

    override fun initLayout(): Int {
        return R.layout.fragment_search_history
    }

    override fun initData(arguments: Bundle?) {
    }

    override fun initView(view: View) {
        rv_hot_search.layoutManager = FlexboxLayoutManager(activity)
        rv_hot_search.adapter = mHotSearchAdapter

        rv_history_search.layoutManager = FlexboxLayoutManager(activity)
        rv_history_search.adapter = mHistorySearchAdapter
    }

    override fun loadData() {
        val dataList = mutableListOf(
            "999",
            "感冒灵", "感冒感康感冒感康感冒感康感冒感康感冒感康感冒感康感冒感康感冒感康感冒感康",
            "退烧药", "酵素", "头疼"
        )
        mHotSearchAdapter.replaceData(dataList)
        mHistorySearchAdapter.replaceData(dataList)
    }

}